/**
 * 0202
 *
 * @Author : Ruoyu Wang
 * @DateTime : 2024/8/12 22:23
 */

#include <iostream>
#include <vector>
#include "unordered_set"

using namespace std;

class Solution {
private:
    unordered_set<int> set;
public:
    bool isHappy(int n) {
        while (n != 1) {
            if (set.count(n))return false;
            set.insert(n);
            int x = 0;
            while (n) {
                x += (n % 10) * (n % 10);
                n /= 10;
            }
            n = x;
        }
        return true;
    }
};

int main() {

    return 0;
}